package fudan.se.project.repository.projection.summary;

import fudan.se.project.domain.conference.production.Writer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;

public class WriterSummary {

    private Writer writer;


    public WriterSummary(Writer writer) {
        this.writer = writer;
    }

    public long getId() {
        return writer.getId();
    }

    public String getRealname() {
        return writer.getRealname();
    }

    public String getEmail() {
        return writer.getEmail();
    }

    public String getOrganization() {
        return writer.getOrganization();
    }

    public String getRegion() {
        return writer.getRegion();
    }

    public static WriterSummary summarize(Writer writer) {
        return new WriterSummary(writer);
    }

    public static List<WriterSummary> summarize(Collection<Writer> writers) {
        ArrayList<Writer> writerArrayList = new ArrayList<>(writers);
        writerArrayList.sort(Comparator.comparingInt(Writer::getIndex));

        ArrayList<WriterSummary> arrayList = new ArrayList<>(writers.size());
        for (Writer value : writerArrayList) {
            arrayList.add(summarize(value));
        }
        return arrayList;
    }
}
